﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using BCCommon.FreightEnums;
using BCEntity.Common.Area;

namespace BCData.Common.Area
{
    public interface ICityData
    {
        /// <summary>
        /// 添加城市信息
        /// </summary>
        /// <param name="dto">城市请求信息</param>
        /// <returns></returns>
        bool Add(CityEntity entity);
        /// <summary>
        /// 修改城市信息
        /// </summary>
        /// <param name="dto">城市请求信息</param>
        /// <returns></returns>
        bool Update(CityEntity entity);
        /// <summary>
        /// 删除城市信息
        /// </summary>
        /// <param name="cityCode">城市Id</param>
        bool Delete(string cityCode);
        /// <summary>
        /// 获取城市信息单条
        /// </summary>
        /// <param name="cityId">城市Id</param>
        /// <returns></returns>
        CityEntity GetCity(long cityId);
        /// <summary>
        /// 获取城市信息单条
        /// </summary>
        /// <param name="cityCode">城市Id</param>
        /// <returns></returns>
        CityEntity GetCity(string cityCode);
        /// <summary>
        /// 获取省会城市列表
        /// </summary>
        /// <param name="provinceCode">省份编码</param>
        /// <returns></returns>
        IEnumerable<CityEntity> GetCommunities(string provinceCode);
        /// <summary>
        /// 获取省会城市列表
        /// </summary>
        /// <param name="provinceId">省份Id</param>
        /// <returns></returns>
        IEnumerable<CityEntity> GetCommunities(long provinceId);
        /// <summary>
        /// 获取城市列表
        /// </summary>
        /// <param name="provinceCode">省份Id</param>
        /// <param name="cityCode">市Id</param>
        /// <param name="index">当前页码</param>
        /// <param name="size">每页数据条数</param>
        /// <param name="dataCount">数据总数</param>
        /// <returns></returns>
        IEnumerable<CityEntity> GetCommunities(string provinceCode, string cityCode, int index, int size, out int dataCount);
        /// <summary>
        /// 检查城市是否已存在
        /// </summary>
        /// <param name="cityId">城市Id</param>
        /// <returns></returns>
        bool CheckExistsById(long cityId);
        /// <summary>
        /// 检查城市是否已存在
        /// </summary>
        /// <param name="cityCode">城市编码</param>
        /// <returns></returns>
        bool CheckExistsByCode(string cityCode);
        /// <summary>
        /// 检查城市是否已存在
        /// </summary>
        /// <param name="provinceCode">省份编码</param>
        /// <param name="cityCode">城市编码</param>
        /// <returns></returns>
        bool CheckExistsByName(string provinceCode, string cityCode);

        /// <summary>
        /// 获取城市列表--首字母分组
        /// </summary>
        /// <returns></returns>
        IEnumerable<CityEntity> GetCommunitiesInitialsGroup();
        /// <summary>
        /// 获取热门城市列表
        /// </summary>
        /// <returns></returns>
        IEnumerable<CityEntity> GetHotCommunities();
        /// <summary>
        /// 修改城市议价
        /// </summary>
        /// <param name="cityCode">城市Id</param>
        /// <param name="businessType">业务类型</param>
        /// <param name="isNegotiatedPrice">需要议价</param>
        /// <returns></returns>
        Task<int> UpdateCityNegotiatedPrice(string cityCode, FreightBusinessType businessType, bool isNegotiatedPrice);
        /// <summary>
        /// 修改所有城市议价
        /// </summary>
        /// <param name="provinceCode">省份编码</param>
        /// <param name="businessType">业务类型</param>
        /// <param name="isNegotiatedPrice">需要议价</param>
        /// <returns></returns>
        Task<int> UpdateAllCityNegotiatedPrice(string provinceCode, FreightBusinessType businessType, bool isNegotiatedPrice);
        /// <summary>
        /// 所有城市
        /// </summary>
        /// <returns></returns>
        IEnumerable<CityEntity> GetAllCity();

        /// <summary>
        /// 检查市信息是否存在
        /// </summary>
        /// <param name="cityUuid">市UUID</param>
        /// <param name="cityName">市名称</param>
        /// <param name="cityCode">市编码</param>
        /// <param name="provinceCode">省编码</param>
        /// <returns></returns>
        Task<CityEntity> GetCityAsync(string cityUuid, string cityName, string cityCode, string provinceCode);

        /// <summary>
        /// 添加市信息
        /// </summary>
        /// <param name="entity">市信息</param>
        /// <param name="batchNo">批号</param>
        /// <returns></returns>
        Task<int> AddCityAsync(CityEntity entity, string batchNo);

        /// <summary>
        /// 更新市信息
        /// </summary>
        /// <param name="entity">新市信息</param>
        /// <param name="batchNo">批号</param>
        /// <param name="cityResult">旧市信息</param>
        /// <param name="isMatch">是否匹配上</param>
        /// <returns></returns>
        Task<int> UpdateCityAsync(CityEntity entity, string batchNo, CityEntity cityResult, bool? isMatch);

        /// <summary>
        /// 不存在新地图信息插入未匹配上的数据
        /// </summary>
        /// <param name="batchNo">批号</param>
        /// <returns></returns>
        Task<bool> UpdateIsEnabledAsync(string batchNo);
    }
}
